<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="prev" href="player-objects.html" />
<link rel="parent" href="module-cd.html" />
<link rel="next" href="module-fl.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>34.3.2 Parser Objects</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="34.3.1 player Objects"
  href="player-objects.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="34.3 cd  "
  href="module-cd.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="34.4 fl  "
  href="module-fl.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="player-objects.html">34.3.1 Player Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-cd.html">34.3 cd  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-fl.html">34.4 fl  </a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION0036320000000000000000"></a>
<a name="cd-parser-objects"></a>
<br>
34.3.2 Parser Objects
</h2>

<p>
Parser objects (returned by <tt class="function">createparser()</tt>) have the
following methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5617' xml:id='l2h-5617' class="method">addcallback</tt></b>(</nobr></td>
  <td><var>type, func, arg</var>)</td></tr></table></dt>
<dd>
Adds a callback for the parser.  The parser has callbacks for eight
different types of data in the digital audio data stream.  Constants
for these types are defined at the <tt class="module">cd</tt> module level (see above).
The callback is called as follows: <code><var>func</var>(<var>arg</var>, type,
data)</code>, where <var>arg</var> is the user supplied argument, <var>type</var> is
the particular type of callback, and <var>data</var> is the data returned
for this <var>type</var> of callback.  The type of the data depends on the
<var>type</var> of callback as follows:

<p>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Type</th>
      <th class="left"  >Value</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline"><code>audio</code></td>
        <td class="left"  >String which can be passed unmodified to
<tt class="function">al.writesamps()</tt>.</td></tr>
    <tr><td class="left"   valign="baseline"><code>pnum</code></td>
        <td class="left"  >Integer giving the program (track) number.</td></tr>
    <tr><td class="left"   valign="baseline"><code>index</code></td>
        <td class="left"  >Integer giving the index number.</td></tr>
    <tr><td class="left"   valign="baseline"><code>ptime</code></td>
        <td class="left"  >Tuple consisting of the program time in minutes,
seconds, and frames.</td></tr>
    <tr><td class="left"   valign="baseline"><code>atime</code></td>
        <td class="left"  >Tuple consisting of the absolute time in minutes,
seconds, and frames.</td></tr>
    <tr><td class="left"   valign="baseline"><code>catalog</code></td>
        <td class="left"  >String of 13 characters, giving the catalog number
of the CD.</td></tr>
    <tr><td class="left"   valign="baseline"><code>ident</code></td>
        <td class="left"  >String of 12 characters, giving the ISRC
identification number of the recording.  The string consists of two
characters country code, three characters owner code, two characters
giving the year, and five characters giving a serial number.</td></tr>
    <tr><td class="left"   valign="baseline"><code>control</code></td>
        <td class="left"  >Integer giving the control bits from the CD
subcode data</td></tr></tbody>
</table></div>
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5618' xml:id='l2h-5618' class="method">deleteparser</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Deletes the parser and frees the memory it was using.  The object
should not be used after this call.  This call is done automatically
when the last reference to the object is removed.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5619' xml:id='l2h-5619' class="method">parseframe</tt></b>(</nobr></td>
  <td><var>frame</var>)</td></tr></table></dt>
<dd>
Parses one or more frames of digital audio data from a CD such as
returned by <tt class="method">readda()</tt>.  It determines which subcodes are
present in the data.  If these subcodes have changed since the last
frame, then <tt class="method">parseframe()</tt> executes a callback of the
appropriate type passing to it the subcode data found in the frame.
Unlike the C function, more than one frame of digital audio data
can be passed to this method.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5620' xml:id='l2h-5620' class="method">removecallback</tt></b>(</nobr></td>
  <td><var>type</var>)</td></tr></table></dt>
<dd>
Removes the callback for the given <var>type</var>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5621' xml:id='l2h-5621' class="method">resetparser</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Resets the fields of the parser used for tracking subcodes to an
initial state.  <tt class="method">resetparser()</tt> should be called after the disc
has been changed.
</dl>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="34.3.1 player Objects"
  href="player-objects.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="34.3 cd  "
  href="module-cd.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="34.4 fl  "
  href="module-fl.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="player-objects.html">34.3.1 Player Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-cd.html">34.3 cd  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-fl.html">34.4 fl  </a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
